package eerbaar.v2.pattern.client.internal.readers;

import eerbaar.game.IGame;
import eerbaar.memory.IMemory;
import eerbaar.persona.IPersona;
import eerbaar.shared.message.IMessageReader;
import eerbaar.shared.message.Message;
import eerbaar.v2.app.GameHelper;
import eerbaar.v2.pattern.client.internal.teach.TeachingMediator;

public class LevelChangeReader implements IMessageReader {

    @Override
    public boolean read(Message msg) {

        IGame game = GameHelper.getGame();
        if (game == null) {
            return false;
        }

        IPersona pet = game.getPersona("pet");
        IMemory memory = pet.getHead().getBrain().getMemory();
        int count = memory.getIdeaNode().getChildCount();
        if (count > 0) {
            TeachingMediator.getInstance().addFreePlayMenu();
        } else {
            TeachingMediator.getInstance().removeFreePlayMenu();
        }

        return false;
    }

}
